// pages/backRecord/backRecord.js
var util = require("../../utils/util.js");
const APP = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageNum: 1,
    pageSize: 3,
    option1: [
      { text: '最新记录', value: 0 },
      { text: '一周前', value: 1 },
      { text: '半月前', value: 2 },
      { text: '一月前', value: 3 },
    ],
    itemTitle: '选择日期',
    value1: 0,
    currentDate: new Date().getTime(),
 
    formatter(type, value) {
      if (type === 'year') {
        return `${value}年`;
      } else if (type === 'month') {
        return `${value}月`;
      }
      return value;
    },
  
    navList:[],
    show: false,
    show1: false,
    title: '',
    paramas:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    let that = this
    that.setData({
      pageNum: that.data.pageNum + 1
    })
    // 获取预约数组
    that.getList();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  
  //获取初始化信息
  getList:function(){ 

    var list = {
      url: '/system/personInterviewer/queryAllPeople?pageNum=' + this.data.pageNum + '&pageSize=' + this.data.pageSize,
      method: 'get',
      data:this.data.paramas
    }
    APP.request.backWxRequest(list).then(res => {
      var navList = this.data.navList
      var rows = res.data.rows
      var allArr = [...navList, ...rows]
      if (res.data.code === 200) {
        this.setData({
          navList: allArr
        })
      }
    })
 
  },
//搜索
  onClick:function(){
    this.setData({
      pageNum: 1,
      pageSize: 4,
      navList: []
    })
    this.getList();
  },
  onChange(e) {
    
    this.setData({
      paramas: {
        userName: e.detail,
      }
    });
  },
  onSearch() {
    this.setData({
      pageNum: 1,
      pageSize: 4,
      navList: []
    })
    this.getList();
  },
  //记录
  jilu:function(detail) {
    this.setData({
        paramas:[],
        itemTitle:'选择日期'
    });
    console.log(detail.detail)
    this.setData({
      paramas:{
        timeNum: detail.detail
      }
    });
    this.setData({
      pageNum: 1,
      pageSize: 4,
      navList: []
    })
    this.getList();
  },
  //日期

  sure: function (event){
    var date =event.detail
    this.setData({
      createTime: '',
      itemTitle: util.js_date_time(date),
       paramas: {
         createTime: util.js_date_time(date)
      }
    });
    this.setData({
      pageNum: 1,
      pageSize: 4,
      navList: []
    })
    this.getList();
    this.selectComponent('#item').toggle();
  },

  close:function(){
    this.selectComponent('#item').toggle();
  }
})